package com.example.lancooznbk.utils;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;

/**
 * Created by tangminglong on 17/7/29.
 */

public class AnimatorHelper {

    private static final int ANIMATOR_DURATION = 800;
    private static final Interpolator mInterpolator = new LinearInterpolator();

    public static Animator[] getRecyclerAnimator(View itemView,boolean isScrollDown){
        ObjectAnimator tranY = isScrollDown ?
                ObjectAnimator.ofFloat(itemView, "translationY", itemView.getMeasuredHeight(), 0):
                ObjectAnimator.ofFloat(itemView, "translationY", -itemView.getMeasuredHeight(),0);
        ObjectAnimator scaleX = ObjectAnimator.ofFloat(itemView, "scaleX", 0.8f, 1f);
        ObjectAnimator scaleY = ObjectAnimator.ofFloat(itemView, "scaleY", 0.8f, 1f);
        ObjectAnimator alpha = ObjectAnimator.ofFloat(itemView, "alpha", 1f, 1f);
        tranY.setDuration(ANIMATOR_DURATION); tranY.setInterpolator(mInterpolator);
        scaleX.setDuration(ANIMATOR_DURATION); scaleX.setInterpolator(mInterpolator);
        scaleY.setDuration(ANIMATOR_DURATION); scaleY.setInterpolator(mInterpolator);
        alpha.setDuration(ANIMATOR_DURATION); alpha.setInterpolator(mInterpolator);

        return new Animator[] { tranY,scaleX,scaleY,alpha };
    }
}
